#include <stdio.h>
int yearday(int, int, int);
int years[13] = {0 , 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main()
{
    int year, month, day;
    while( scanf("%d %d %d", &year, &month, &day) != EOF )
        printf("%d\n", yearday(year, month, day));
    return 0;
}
int yearday(int year, int month, int day){
    int days = 0;
    for( int i = 1; i < month; i ++)
        days += years[i];
    days += day;
    if( month > 2)
        if( year % 400 == 0 || (year %4 == 0 && year % 100 != 0))
            days ++;
    return days;
}